// pages/parentsList/parentsList.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    popBgShow: false,
    sexualList: [{
      id: 0,
      onthis: true,
      img: '../../images/parents_icon.png',
      name: '关爱父母'
    }, {
      id: 1,
      onthis: false,
      img: '../../images/married_female_icon.png',
      name: '女士体检'
    }, {
      id: 2,
      onthis: false,
      img: '../../images/male_icon.png',
      name: '男士体检'
    }],
    //机构列表
    placeList: [{
      id: 0,
      img: '../../images/place_demo.jpg',
      name: '中智定制胸片CT',
      attr: ['属性1', '属性2', '属性3'],
      color: 'orange',
      price: '160.00'
    }, {
      id: 1,
      img: '../../images/place_demo.jpg',
      name: '中智定制版颈椎版',
      attr: ['属性1', '属性2', '属性3'],
      color: 'orange',
      price: '360.00'
    }, {
      id: 2,
      img: '../../images/place_demo.jpg',
      name: '中智定制版经典版',
      attr: ['属性1', '属性2', '属性3'],
      color: '',
      price: '560.00'
    }, {
      id: 3,
      img: '../../images/place_demo.jpg',
      name: '中智定制版经典版',
      attr: ['属性1', '属性2', '属性3'],
      color: 'orange',
      price: '560.00'
    }],
    //筛选列表
    chooseList: [{
      cType: 'ptype',
      title: '适用人群',
      items: [{
        id: '01',
        value: 'ptype',
        name: '关爱父母',
        onthis: false
      }, {
        id: '02',
        value: 'ptype',
        name: '女士体检',
        onthis: false
      }, {
        id: '03',
        value: 'ptype',
        name: '男士体检',
        onthis: false
      }]
    }, {
      cType: 'budget',
      title: '套餐预算',
      items: [{
        id: '11',
        value: 'budget',
        name: '300以下',
        onthis: false
      }, {
        id: '12',
        value: 'budget',
        name: '300-800',
        onthis: false
      }, {
        id: '13',
        value: 'budget',
        name: '800-1500',
        onthis: false
      }, {
        id: '14',
        value: 'budget',
        name: '1500-3000',
        onthis: false
      }, {
        id: '15',
        value: 'budget',
        name: '3000以上',
        onthis: false
      }]
    }, {
      cType: 'job',
      title: '职业特点',
      items: [{
        id: '21',
        value: 'job',
        name: '程序员',
        onthis: false
      }, {
        id: '22',
        value: 'job',
        name: '白领精英',
        onthis: false
      }, {
        id: '23',
        value: 'job',
        name: '高层管理',
        onthis: false
      }]
    }, {
      cType: 'disease',
      title: '疾病方向',
      items: [{
        id: '31',
        value: 'disease',
        name: '肿瘤筛查',
        onthis: false
      }, {
        id: '32',
        value: 'disease',
        name: '脊椎',
        onthis: false
      }, {
        id: '33',
        value: 'disease',
        name: '糖尿病',
        onthis: false
      }]
    }]
  },
  onLoad: function(options) {

  },
  chooseSexual: function(e) {
    let id = e.currentTarget.id,
      list = this.data.sexualList;
    for (let i = 0; i < list.length; i++) {
      list[i].onthis = false;
      if (id == list[i].id) {
        list[i].onthis = true;
      }
    }
    this.setData({
      sexualList: list
    })
  },
  moreChoose: function(e) {
    this.setData({
      popBgShow: true
    })
  },
  closePop: function(e) {
    this.setData({
      popBgShow: false
    })
  },
  chooseTap: function(e) {
    let list = this.data.chooseList,
      id = e.currentTarget.id,
      value = e.currentTarget.dataset.value;
    for (let i = 0; i < list.length; i++) {
      for (let j = 0; j < list[i].items.length; j++) {
        if (value == list[i].cType) {
          list[i].items[j].onthis = false;
        }
        if (id == list[i].items[j].id) {
          list[i].items[j].onthis = true;
        }
      }
    }
    this.setData({
      chooseList: list
    })
  },
  clearChoose: function(e) {
    let list = this.data.chooseList;
    for (let i = 0; i < list.length; i++) {
      for (let j = 0; j < list[i].items.length; j++) {
        list[i].items[j].onthis = false;
      }
    }
    this.setData({
      chooseList: list
    })
  },
  confirmChoose: function(e) {
    this.setData({
      popBgShow: false
    })
  }
})